package com.cjgl.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cjgl.common.ErrorCode;
import com.cjgl.exception.BusinessException;
import com.cjgl.mapper.TblCoursestableMapper;
import com.cjgl.model.entity.TblCoursestable;
import com.cjgl.service.TblCoursestableService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author zhangyuwu
 * @description 针对表【tbl_coursestable(课程表)】的数据库操作Service实现
 * @createDate 2023-05-24 13:49:32
 */
@Service
public class TblCoursestableServiceImpl extends ServiceImpl<TblCoursestableMapper, TblCoursestable>
		implements TblCoursestableService {


	/**
	 * 根据老师工号查询老师的课表
	 *
	 * @param teacherNo
	 * @param term
	 * @return
	 */
	@Override
	public List<TblCoursestable> getCoursestableList(String teacherNo, String term) {
		if (StringUtils.isBlank(term)) {
			throw new BusinessException(ErrorCode.PARAMS_ERROR);
		}
		LambdaQueryWrapper<TblCoursestable> tblCoursestableQueryWrapper = new LambdaQueryWrapper<>();
		tblCoursestableQueryWrapper.eq(TblCoursestable::getTeacherNo, teacherNo);
		tblCoursestableQueryWrapper.like(TblCoursestable::getTeacherNo, term);
		List<TblCoursestable> tblCoursestables = baseMapper.selectList(tblCoursestableQueryWrapper);
		return tblCoursestables;
	}
}




